const CACHE_CONST = {}
import { getDictionatyByType } from '@/api/dictionary'
export async function getOptions(type) {
  let CONST = CACHE_CONST[type]
  if (CONST) {
    return CONST
  }
  const ret = await getDictionatyByType({type})
  CONST = ret || []
  CACHE_CONST[type] = ret
  return CONST
}

export async function fmtClcd(type, value) {
  const desc = await getOptions(type)
  if (desc.length) {
    /* eslint-disable */
    const dicData = desc.find(item => (item.code == value))
    return dicData ? dicData.value : value
  }
  return value
}
